var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, n, a) {
    var i, r = arguments.length, o = r < 3 ? t : null === a ? a = Object.getOwnPropertyDescriptor(t, n) : a;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o = Reflect.decorate(e, t, n, a); else for (var l = e.length - 1; 0 <= l; l--) (i = e[l]) && (o = (r < 3 ? i(o) : 3 < r ? i(t, n, o) : i(t, n)) || o);
    return 3 < r && o && Object.defineProperty(t, n, o), o;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("MyScrollView"), s = e("Global"), c = e("SeasonItemTop"), l = e("GameData"), d = e("WebManager"), u = cc._decorator, p = u.ccclass, h = u.property, f = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.topItemPrefab = null, e.points = [ cc.v2(-5, 215), cc.v2(-195, 200), cc.v2(185, 185) ], 
        e.rankLabel = null, e;
    }
    return i(e, t), e.prototype.start = function() {
        this.initRank();
    }, e.prototype.initRank = function() {
        var i = this;
        s.G.isNative() ? d.default.getInstance().getSomeRobots({
            limit: 50,
            success: function(a) {
                d.default.getInstance().reqRank({
                    success: function(n) {
                        var e;
                        console.log("reqRank", JSON.stringify(n)), 0 == n.data.code && (n.data.data.rankList instanceof Array && (e = n.data.data.rankList.sort(function(e, t) {
                            return isNaN(e.level) || isNaN(e.killNum) ? 1 : isNaN(t.level) || isNaN(t.killNum) ? -1 : e.level === t.level ? t.level + t.killNum - (e.level + e.killNum) : t.level - e.level;
                        }).map(function(e, t) {
                            return n.data.data.userRank.openid == e.openid ? (e.nickname = "我", e.personIdx = l.GD.personIdx) : (e.nickname = a.data.data[t].nickname, 
                            e.personIdx = s.G.personModelList[GA.rand(0, s.G.personModelList.length - 1)].id), 
                            {
                                rank: t + 1,
                                openid: e.openid,
                                level: e.level,
                                killNum: e.killNum,
                                avatarUrl: e.headpic,
                                nickname: e.nickname,
                                personIdx: e.personIdx
                            };
                        }), i.init(e.filter(function(e) {
                            return 3 < e.rank;
                        })), i.initTop(e.filter(function(e) {
                            return e.rank < 4;
                        }))), i.initSelf(n.data.data.userRank));
                    }
                });
            }
        }) : d.default.getInstance().reqRank({
            success: function(e) {
                var t;
                console.log("reqRank", e), 0 == e.data.code && (e.data.data.rankList instanceof Array && (t = e.data.data.rankList.sort(function(e, t) {
                    return isNaN(e.level) || isNaN(e.killNum) ? 1 : isNaN(t.level) || isNaN(t.killNum) ? -1 : e.level === t.level ? t.level + t.killNum - (e.level + e.killNum) : t.level - e.level;
                }).map(function(e, t) {
                    return {
                        rank: t + 1,
                        openid: e.openid,
                        level: e.level,
                        killNum: e.killNum,
                        avatarUrl: e.headpic,
                        nickname: e.nickname
                    };
                }), i.init(t.filter(function(e) {
                    return 3 < e.rank;
                })), i.initTop(t.filter(function(e) {
                    return e.rank < 4;
                }))), i.initSelf(e.data.data.userRank));
            }
        });
    }, e.prototype.initTop = function(e) {
        var a = this;
        e.forEach(function(e, t) {
            var n;
            t < a.points.length && ((n = cc.instantiate(a.topItemPrefab)).parent = a.node, n.setPosition(a.points[t]), 
            n.getComponent(c.default).init(e));
        });
    }, e.prototype.initSelf = function(e) {
        50 < e.rank ? this.rankLabel.string = "排名:50名+" : this.rankLabel.string = "排名:" + e.rank + "名";
    }, a([ h(cc.Prefab) ], e.prototype, "topItemPrefab", void 0), a([ h(cc.Label) ], e.prototype, "rankLabel", void 0), 
    a([ p ], e);
}(r.default);

n.default = f;